<!DOCTYPE html>
<html style="width: fit-content">
<head>
<title>jomjol - AI on the edge</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<style>
.h_iframe iframe {width:995px;height:605px;}
.h_iframe {width:995px;height:605px;}

h1 {font-size: 2em; margin-block-end: 0.3em;}
h2 {font-size: 1.5em;margin-block-start: 0.3em;}
h3 {font-size: 1.2em;}
p {font-size: 1em;}


.button {
	padding: 5px 20px;
    width: 211px;
	font-size: 16px;	
}


</style>
</head>

<body style="font-family: arial">

    <h4>Finished!</h4>

    <p>
        Now you are finished with the setup and ready to reboot to the normal mode.
        <br>
        Once you have pushed below button, the setup modus will be left and the digitizer start to normal operation mode.
        <br>
        After a view seconds you can reload this page again and will go to normal operation mode. 
        <br>
        All settings can be changed later on as well in the configuration menue.
    </p>

    <p>
        <button class="button" onclick="reboot()">Leave Setup Modus and Reboot to Normal</button>
    </p>

    <script type="text/javascript" src="./gethost.js"></script> 
    <script type="text/javascript" src="./readconfigparam.js"></script> 
    <script type="text/javascript" src="./readconfigcommon.js"></script> 

    <script type="text/javascript">
        var canvas = document.getElementById('canvas'),
            basepath = "http://192.168.178.22"; 
            aktstatu = 0;
    
    function reboot() {
        if (confirm("Do you want to leave the configuration mode and restart the ESP32?\n\nPlease reload the page in about 30s.")) {
            basepath = getbasepath(); 
            if (!loadConfig(basepath)) {
                alert("Setup Modus could not be deactivated!\Please retry.");
                return;
            } 
            ParseConfig();	
            param = getConfigParameters();
            param["System"]["SetupMode"]["enabled"] = false;
            param["System"]["SetupMode"]["value1"] = "false";
            setConfigParameters(param);
            var textToSave = setConfigParameters(param);
		    FileDeleteOnServer("/config/config.ini", basepath);
		    FileSendContent(textToSave, "/config/config.ini", basepath);

            var stringota = "/reboot";
            window.location = stringota;
            window.location.href = stringota;
            window.location.assign(stringota);
            window.location.replace(stringota);
        }
    }

    </script>

</body>
</html>